<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_notaFiscal.xhtml">
	<ui:define name="corpo"><br />

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="Enviar Nota Fiscal Para Pagamento" />
				</h2>
				<hr /><br />

				<p:messages id="msg" />
				
				<p:fieldset legend="Dados da Nota Fiscal">
				
				<h:panelGrid columns="3">
				
				<h:outputLabel value="Escolha a Nota Fiscal: " for="nota" style="color: red;" />
				<h:outputLink value="javascript:void(0)" onclick="dlgNota.show();">
				<h:graphicImage value="resources/img/lupa3.png" style="width: 40px;" onclick="dlgNota.show();" rendered="#{empty notaFiscalBean.nota.id}" />
					<h:outputText id="nf" value="#{notaFiscalBean.nota.numero}" onclick="dlgNota.show();" rendered="#{not empty notaFiscalBean.nota.id}" />
				</h:outputLink><br /><br />			
				
				<h:outputLabel value="Enviar Para Pagamento: " for="pagamento" style="color: red;" />
				<h:selectBooleanCheckbox id="pagamento" value="#{notaFiscalBean.nota.pagamento}">
					<f:selectItem itemLabel="Enviar Para Pagamento" itemValue="Enviar Para Pagamento" />
				</h:selectBooleanCheckbox><br /><br />
				
				<h:outputLabel value="Data do Envio: " style="color: red;" />
				<p:calendar value="#{notaFiscalBean.nota.data.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar><br /><br />
								
				<h:outputLabel value="Número: " for="numero" />
				<p:inputText id="numero" value="#{notaFiscalBean.nota.numero}" disabled="true">
					<p:ajax event="change"/>
				</p:inputText><br /><br />
				
				<h:outputLabel value="Fornecedor: " for="fornecedor" />
					<h:selectOneMenu value="#{notaFiscalBean.nota.fornecedor}" converter="genericConverter" disabled="true">
						<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
						<f:selectItems value="#{fornecedorBean.fornecedores}" var="fornecedor" itemLabel="#{fornecedor.nome}" itemValue="#{fornecedor}" />
				</h:selectOneMenu><br /><br />
				
				<h:outputLabel value="Empenho: " for="empenho" />
					<h:selectOneMenu value="#{notaFiscalBean.nota.empenho}" converter="genericConverter" disabled="true">
						<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
						<f:selectItems value="#{empenhoBean.empenhos}" var="empenho" itemLabel="#{empenho.numero}" itemValue="#{empenho}" />
				</h:selectOneMenu><br /><br />			
				
				<h:outputLabel value="Data de Emissão: " />
				<p:calendar value="#{notaFiscalBean.nota.data.time}" disabled="true">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar><br /><br />
				
				<h:outputLabel value="Recebido: " />
				<p:calendar value="#{notaFiscalBean.nota.recebido.time}" disabled="true">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar><br /><br />
				
				<h:outputLabel value="Valor Total: " for="valor" />
				<p:inputText id="valor" value="#{notaFiscalBean.nota.valor_total}" disabled="true">
					<f:convertNumber pattern="#,##0.00" />
					<p:ajax event="change" />
				</p:inputText><br /><br />
				
				<h:outputLabel value="Status: " for="status" />
				<h:selectOneMenu id="status" value="#{notaFiscalBean.nota.status}" disabled="true">
					<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" ></f:selectItem>
					<f:selectItem itemLabel="Recebido" itemValue="Recebido" />
					<f:selectItem itemLabel="Pendente" itemValue="Pendente" />
					<f:selectItem itemLabel="Aguardando Material" itemValue="Aguardando Material" />
				</h:selectOneMenu><br /><br />
				
				<div style="float: right; text-align: left; ">
						<h:outputLabel value="Observação: " for="obs" />
						<p:inputTextarea id="obs" value="#{notaFiscalBean.nota.obs}"
							style="width: 480px" disabled="true">
							<f:ajax event="change" />
						</p:inputTextarea>
				</div>
				
				<p:commandButton id="grava" value="Enviar" action="#{notaFiscalBean.grava}" ajax="false" image="ui-icon-disk" rendered="#{not empty notaFiscalBean.nota.id}">
					<f:ajax render="@all" />
				</p:commandButton>
				
				<p:commandButton id="cancel" value="CANCELAR EDIÇÃO" action="formEnviarNotaFiscalParaPagamento.xhtml"
						rendered="#{not empty notaFiscalBean.nota.id}" ajax="false" icon="ui-icon-arrowreturnthick-1-w">
						<f:ajax render="@all" />
				</p:commandButton><br /><br />
				
				</h:panelGrid>

				</p:fieldset>
				
				</h:form>
				
				<p:dialog header="Nota Fiscais Cadastradas" widgetVar="dlgNota" width="500">
					<h:form id="form1">

						<p:outputPanel id="notas">
							<p:dataTable value="#{notaFiscalBean.notas}" var="nota" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{nota.numero}" filterMatchMode="contains"
									headerText="Numero">
									<h:commandLink value="#{nota.numero}" onclick="dlgNota.hide()"
										id="nota">
										<f:setPropertyActionListener
											target="#{notaFiscalBean.nota}" value="#{nota}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Fornecedor">
									<h:outputText value="#{nota.fornecedor.nome}" />
								</p:column>
			
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>

<!-- 			<h:form id="form2"> -->
				
<!-- 				<p:dataTable id="listNota" value="#{notaFiscalBean.notas}" emptyMessage="Não Encontrado" -->
<!-- 					var="nota" paginator="true" rows="5" style="font-size: 12px"> -->

<!-- 					<f:facet name="header"> -->
<!-- 						<h:outputText value="NOTAS FISCIAS" /> -->
<!-- 					</f:facet> -->

<!-- 					<p:column sortBy="#{nota.numero}" filterBy="#{nota.numero}" filterMatchMode="contains" -->
<!-- 						headerText="Número" style="width: 100px;"> -->
<!-- 						<h:outputText value="#{nota.numero}" /> -->
<!-- 					</p:column> -->
					
<!-- 					<p:column sortBy="#{nota.empenho.numero}" filterBy="#{nota.empenho.numero}" filterMatchMode="contains" -->
<!-- 						headerText="Empenho" style="width: 150px; float: center; text-align: center;"> -->
<!-- 						<h:outputText value="#{nota.empenho.numero}" /> -->
<!-- 					</p:column> -->

<!-- 					<p:column sortBy="#{nota.fornecedor.nome}" filterBy="#{nota.fornecedor.nome}" filterMatchMode="contains" -->
<!-- 						headerText="Fornecedor"> -->
<!-- 						<h:outputText value="#{nota.fornecedor.nome}" />	 -->
<!-- 					</p:column> -->
					
<!-- 					<p:column headerText="Opções" style="float: center; text-align: center;"> -->
<!-- 						<p:commandButton value="Enviar Para Pagamento" ajax="false" style="background: #87CEFA; color: black;"> -->
<!-- 							<f:setPropertyActionListener value="#{notaFiscal}" target="#{notaFiscalBean.notaFiscal}" /> -->
<!-- 							<f:ajax render="@form" /> -->
<!-- 						</p:commandButton>	 -->
<!-- 					</p:column> -->
					
<!-- 				</p:dataTable> -->
				
<!-- 			</h:form>	 -->
				
		</div>


	</ui:define>
</ui:composition>
</html>